﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocumentsTagger.DM;

namespace WinFormTagger
{
    public delegate void DocumentFoundHandler(Document doc);
    

    public class MainWindowViewModel
    {
        private readonly List<Document> r_Docs = new List<Document>();
        public event DocumentFoundHandler DocumentFound;

        private void OnDocumentFound(Document FoundDoc)
        {
            if (DocumentFound != null)
            {
                DocumentFound(FoundDoc);
            }
        }

        public void init()
        {
            UpdateDocuments();
        }

        private void UpdateDocuments()
        {
            foreach (Document doc in Program.taggerBL.GetDocuments())
            {
                if (!r_Docs.Contains(doc))
                {
                    r_Docs.Add(doc);
                    OnDocumentFound(doc);
                }
            }
        }
    }
}
